home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Technology Seed / August 1998 ADC Seed CD.toast / Mac OS 8.5b2 / allegro-b2-pseudo-SDK / AIncludes / UnicodeUtilities.a < prev   
Encoding:
Text File  |  1998-07-17  |  13.0 KB  |  272 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        UnicodeUtilities.a
  3. ;
  4. ;    Contains:    Types, constants, prototypes for Unicode Utilities (Unicode input and text utils)
  5. ;
  6. ;    Version:    Technology:    Allegro
  7. ;                Release:    Allego Seed, Use with 3.1 Universal Interfaces
  8. ;
  9. ;    Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__UNICODEUTILITIES__') = 'UNDEFINED' THEN
  19. __UNICODEUTILITIES__ SET 1
  20.  
  21.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  22.     include 'MacTypes.a'
  23.     ENDIF
  24.  
  25.  
  26. ;   -------------------------------------------------------------------------------------------------
  27. ;   CONSTANTS & DATA STRUCTURES
  28. ;   -------------------------------------------------------------------------------------------------
  29.  
  30.  
  31.  
  32. ;   -------------------------------------------------------------------------------------------------
  33. ;   UCKeyOutput & related stuff
  34. ;   The interpretation of UCKeyOutput depends on bits 15-14.
  35. ;   If they are 01, then bits 0-13 are an index in UCKeyStateRecordsIndex (resource-wide list).
  36. ;   If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  37. ;     or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  38. ;     then bits 0-15 are a single Unicode character.
  39. ;   Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  40. ;     output.
  41. ;   UCKeyCharSeq is similar, but does not support indices in UCKeyStateRecordsIndex. For bits 15-14:
  42. ;   If they are 10, then bits 0-13 are an index in UCKeySequenceDataIndex (resource-wide list),
  43. ;     or if UCKeySequenceDataIndex is not present or the index is beyond the end of the list,
  44. ;     then bits 0-15 are a single Unicode character.
  45. ;   Otherwise, bits 0-15 are a single Unicode character; a value of 0xFFFE-0xFFFF means no character
  46. ;     output.
  47. ;   -------------------------------------------------------------------------------------------------
  48.  
  49.  
  50.  
  51. ; typedef UInt16                         UCKeyOutput
  52.  
  53. ; typedef UInt16                         UCKeyCharSeq
  54.  
  55.  
  56. kUCKeyOutputStateIndexMask        EQU        $4000
  57. kUCKeyOutputSequenceIndexMask    EQU        $8000
  58. kUCKeyOutputTestForIndexMask    EQU        $C000                ; test bits 14-15
  59. kUCKeyOutputGetIndexMask        EQU        $3FFF                ; get bits 0-13
  60.  
  61. ;   -------------------------------------------------------------------------------------------------
  62. ;   UCKeyStateRecord & related stuff
  63. ;   The UCKeyStateRecord information is used as follows. If the current state is zero,
  64. ;   output stateZeroCharData and set the state to stateZeroNextState. If the current state
  65. ;   is non-zero and there is an entry for it in stateEntryData, then output the corresponding
  66. ;   charData and set the state to nextState. Otherwise, output the state terminator from
  67. ;   UCKeyStateTerminators for the current state (or nothing if there is no UCKeyStateTerminators
  68. ;   table or it has no entry for the current state), then output stateZeroCharData and set the
  69. ;   state to stateZeroNextState.
  70. ;   -------------------------------------------------------------------------------------------------
  71.  
  72.  
  73.  
  74. UCKeyStateRecord        RECORD 0
  75. stateZeroCharData         ds.w    1                ; offset: $0 (0)
  76. stateZeroNextState         ds.w    1                ; offset: $2 (2)
  77. stateEntryCount             ds.w    1                ; offset: $4 (4)
  78. stateEntryFormat         ds.w    1                ; offset: $6 (6)
  79. ;  This is followed by an array of stateEntryCount elements
  80. ;  in the specified format. Here we just show a dummy array.
  81. stateEntryData             ds.l    1                ; offset: $8 (8) <-- really an array of length one
  82. sizeof                     EQU *                    ; size:   $C (12)
  83.                         ENDR
  84.  
  85. ;   Here are the codes for entry formats currently defined.
  86. ;   Each entry maps from curState to charData and nextState.
  87.  
  88.  
  89.  
  90. kUCKeyStateEntryTerminalFormat    EQU        $0001
  91. kUCKeyStateEntryRangeFormat        EQU        $0002
  92.  
  93. ;   For UCKeyStateEntryTerminal -
  94. ;   nextState is always 0, so we don't have a field for it
  95.  
  96.  
  97.  
  98. UCKeyStateEntryTerminal    RECORD 0
  99. curState                 ds.w    1                ; offset: $0 (0)
  100. charData                 ds.w    1                ; offset: $2 (2)
  101. sizeof                     EQU *                    ; size:   $4 (4)
  102.                         ENDR
  103.  
  104. ;   For UCKeyStateEntryRange -
  105. ;   If curState >= curStateStart and curState <= curStateStart+curStateRange,
  106. ;   then it matches the entry, and we transform charData and nextState as follows:
  107. ;   If charData < 0xFFFE, then charData += (curState-curStateStart)*deltaMultiplier
  108. ;   If nextState != 0, then nextState += (curState-curStateStart)*deltaMultiplier
  109.  
  110.  
  111. UCKeyStateEntryRange    RECORD 0
  112. curStateStart             ds.w    1                ; offset: $0 (0)
  113. curStateRange             ds.b    1                ; offset: $2 (2)
  114. deltaMultiplier             ds.b    1                ; offset: $3 (3)
  115. charData                 ds.w    1                ; offset: $4 (4)
  116. nextState                 ds.w    1                ; offset: $6 (6)
  117. sizeof                     EQU *                    ; size:   $8 (8)
  118.                         ENDR
  119.  
  120. ;   -------------------------------------------------------------------------------------------------
  121. ;   UCKeyboardLayout & related stuff
  122. ;   The UCKeyboardLayout struct given here is only for the resource header. It specifies
  123. ;   offsets to the various subtables which each have their own structs, given below.
  124. ;   The keyboardTypeHeadList array selects table offsets that depend on keyboardType. The
  125. ;   first entry in keyboardTypeHeadList is the default entry, which will be used if the
  126. ;   keyboardType passed to UCKeyTranslate does not match any other entry - i.e. does not fall
  127. ;   within the range keyboardTypeFirst..keyboardTypeLast for some entry. The first entry
  128. ;   should have keyboardTypeFirst = keyboardTypeLast = 0.
  129. ;   -------------------------------------------------------------------------------------------------
  130.  
  131.  
  132. UCKeyboardTypeHeader    RECORD 0
  133. keyboardTypeFirst         ds.l    1                ; offset: $0 (0)        ;  first keyboardType in this entry
  134. keyboardTypeLast         ds.l    1                ; offset: $4 (4)        ;  last keyboardType in this entry
  135. keyModifiersToTableNumOffset  ds.l 1            ; offset: $8 (8)        ;  required
  136. keyToCharTableIndexOffset  ds.l    1                ; offset: $C (12)        ;  required
  137. keyStateRecordsIndexOffset  ds.l 1                ; offset: $10 (16)        ;  0 => no table
  138. keyStateTerminatorsOffset  ds.l    1                ; offset: $14 (20)        ;  0 => no table
  139. keySequenceDataIndexOffset  ds.l 1                ; offset: $18 (24)        ;  0 => no table
  140. sizeof                     EQU *                    ; size:   $1C (28)
  141.                         ENDR
  142. UCKeyboardLayout        RECORD 0
  143. ;  header only; other tables accessed via offsets
  144. keyLayoutHeaderFormat     ds.w    1                ; offset: $0 (0)        ;  =kUCKeyLayoutHeaderFormat
  145. keyLayoutDataVersion     ds.w    1                ; offset: $2 (2)        ;  0x0100 = 1.0, 0x0110 = 1.1, etc.
  146. keyLayoutFeatureInfoOffset  ds.l 1                ; offset: $4 (4)        ;  may be 0                                    
  147. keyboardTypeCount         ds.l    1                ; offset: $8 (8)        ;  Dimension for keyboardTypeHeadList[]        
  148. keyboardTypeList         ds        UCKeyboardTypeHeader ; offset: $C (12) <-- really an array of length one
  149. sizeof                     EQU *                    ; size:   $28 (40)
  150.                         ENDR
  151. ;  -------------------------------------------------------------------------------------------------
  152. UCKeyLayoutFeatureInfo    RECORD 0
  153. keyLayoutFeatureInfoFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeyLayoutFeatureInfoFormat
  154. reserved                 ds.w    1                ; offset: $2 (2)
  155. maxOutputStringLength     ds.l    1                ; offset: $4 (4)        ;  longest possible output string
  156. sizeof                     EQU *                    ; size:   $8 (8)
  157.                         ENDR
  158. ;  -------------------------------------------------------------------------------------------------
  159. UCKeyModifiersToTableNum RECORD 0
  160. keyModifiersToTableNumFormat  ds.w 1            ; offset: $0 (0)        ;  =kUCKeyModifiersToTableNumFormat
  161. defaultTableNum             ds.w    1                ; offset: $2 (2)        ;  For modifier combos not in tableNum[]
  162. modifiersCount             ds.l    1                ; offset: $4 (4)        ;  Dimension for tableNum[]
  163. tableNum                 ds.b    1                ; offset: $8 (8) <-- really an array of length one
  164. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  165.                          ORG 10
  166. sizeof                     EQU *                    ; size:   $A (10)
  167.                         ENDR
  168. ;  -------------------------------------------------------------------------------------------------
  169. UCKeyToCharTableIndex    RECORD 0
  170. keyToCharTableIndexFormat  ds.w    1                ; offset: $0 (0)        ;  =kUCKeyToCharTableIndexFormat
  171. keyToCharTableSize         ds.w    1                ; offset: $2 (2)        ;  Max keyCode (128 for ADB keyboards)
  172. keyToCharTableCount         ds.l    1                ; offset: $4 (4)        ;  Dimension for keyToCharTableOffsets[] (usually 6 to 12 tables)
  173. keyToCharTableOffsets     ds.l    1                ; offset: $8 (8) <-- really an array of length one
  174. ;  Each offset in keyToCharTableOffsets is from the beginning of the resource to a
  175. ;  table as follows:
  176. ;     UCKeyOutput        keyToCharData[keyToCharTableSize];
  177. ;  These tables follow the UCKeyToCharTableIndex.
  178. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  179. sizeof                     EQU *                    ; size:   $C (12)
  180.                         ENDR
  181. ;  -------------------------------------------------------------------------------------------------
  182. UCKeyStateRecordsIndex    RECORD 0
  183. keyStateRecordsIndexFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeyStateRecordsIndexFormat
  184. keyStateRecordCount         ds.w    1                ; offset: $2 (2)        ;  Dimension for keyStateRecordOffsets[]
  185. keyStateRecordOffsets     ds.l    1                ; offset: $4 (4) <-- really an array of length one
  186. ;  Each offset in keyStateRecordOffsets is from the beginning of the resource to a
  187. ;  UCKeyStateRecord. These UCKeyStateRecords follow the UCKeyToCharTableIndex.
  188. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  189. sizeof                     EQU *                    ; size:   $8 (8)
  190.                         ENDR
  191. ;  -------------------------------------------------------------------------------------------------
  192. UCKeyStateTerminators    RECORD 0
  193. keyStateTerminatorsFormat  ds.w    1                ; offset: $0 (0)        ;  =kUCKeyStateTerminatorsFormat
  194. keyStateTerminatorCount     ds.w    1                ; offset: $2 (2)        ;  Dimension for keyStateTerminators[] (# of nonzero states)
  195. keyStateTerminators         ds.w    1                ; offset: $4 (4) <-- really an array of length one
  196. ;  Note: keyStateTerminators[0] is terminator for state 1, etc.
  197. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  198. sizeof                     EQU *                    ; size:   $6 (6)
  199.                         ENDR
  200. ;  -------------------------------------------------------------------------------------------------
  201. UCKeySequenceDataIndex    RECORD 0
  202. keySequenceDataIndexFormat  ds.w 1                ; offset: $0 (0)        ;  =kUCKeySequenceDataIndexFormat
  203. charSequenceCount         ds.w    1                ; offset: $2 (2)        ;  Dimension of charSequenceOffsets[] is charSequenceCount+1
  204. charSequenceOffsets         ds.w    1                ; offset: $4 (4) <-- really an array of length one
  205. ;  Each offset in charSequenceOffsets is in bytes, from the beginning of
  206. ;  UCKeySequenceDataIndex to a sequence of UniChars; the next offset indicates the
  207. ;  end of the sequence. The UniChar sequences follow the UCKeySequenceDataIndex.
  208. ;  Then there is padding to a 4-byte boundary with bytes containing 0, if necessary.
  209. sizeof                     EQU *                    ; size:   $6 (6)
  210.                         ENDR
  211. ;  -------------------------------------------------------------------------------------------------
  212. ;  Current format codes for the various tables (bits 12-15 indicate which table)
  213.  
  214.  
  215. kUCKeyLayoutHeaderFormat        EQU        $1002
  216. kUCKeyLayoutFeatureInfoFormat    EQU        $2001
  217. kUCKeyModifiersToTableNumFormat    EQU        $3001
  218. kUCKeyToCharTableIndexFormat    EQU        $4001
  219. kUCKeyStateRecordsIndexFormat    EQU        $5001
  220. kUCKeyStateTerminatorsFormat    EQU        $6001
  221. kUCKeySequenceDataIndexFormat    EQU        $7001
  222.  
  223. ;   -------------------------------------------------------------------------------------------------
  224. ;   Error codes - these will eventually move to Errors.[ahp]
  225. ;   The error code range for Unicode Utilities is -25340 to -25379.
  226. ;   -------------------------------------------------------------------------------------------------
  227.  
  228.  
  229.  
  230.  
  231. kUCOutputBufferTooSmall            EQU        -25340                ; Output buffer too small for Unicode string result
  232.  
  233. ;   -------------------------------------------------------------------------------------------------
  234. ;   Constants for keyAction parameter in UCKeyTranslate() 
  235. ;   -------------------------------------------------------------------------------------------------
  236.  
  237.  
  238.  
  239.  
  240. kUCKeyActionDown                EQU        0                    ; key is going down
  241. kUCKeyActionUp                    EQU        1                    ; key is going up
  242. kUCKeyActionAutoKey                EQU        2                    ; auto-key down
  243. kUCKeyActionDisplay                EQU        3                    ; get information for key display (as in Key Caps)            
  244.  
  245. ;   -------------------------------------------------------------------------------------------------
  246. ;   Bit assignments & masks for keyTranslateOptions parameter in UCKeyTranslate() 
  247. ;   -------------------------------------------------------------------------------------------------
  248.  
  249.  
  250.  
  251.  
  252. kUCKeyTranslateNoDeadKeysBit    EQU        0                    ; Prevents setting any new dead-key states
  253.  
  254. kUCKeyTranslateNoDeadKeysMask    EQU        $00000001
  255.  
  256. ;   -------------------------------------------------------------------------------------------------
  257. ;   FUNCTION PROTOTYPES
  258. ;   -------------------------------------------------------------------------------------------------
  259.  
  260.  
  261.  
  262. ;
  263. ; pascal OSStatus UCKeyTranslate(UCKeyboardLayout *keyLayoutPtr, UInt16 virtualKeyCode, UInt16 keyAction, UInt32 modifierKeyState, UInt32 keyboardType, OptionBits keyTranslateOptions, UInt32 *deadKeyState, UniCharCount maxStringLength, UniCharCount *actualStringLength, UniChar unicodeString[2147483647])
  264. ;
  265.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  266.         IMPORT_CFM_FUNCTION UCKeyTranslate
  267.     ENDIF
  268.  
  269.  
  270.     ENDIF ; __UNICODEUTILITIES__ 
  271.  
  272.